home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / bin / opentool < prev    next >
Encoding:
Text File  |  2010-05-31  |  5.7 KB  |  198 lines

  1. #! /bin/sh
  2. #
  3. # opentool.  Generated from opentool.in by configure.
  4. #
  5. # Copyright (C) 1997 - 2007 Free Software Foundation, Inc.
  6. #
  7. # Author: Scott Predescu <ovidiu@net-community.com>
  8. # Author: Ovidiu Predescu <ovidiu@net-community.com>
  9. # Author: Nicola Pero <nicola.pero@meta-innovation.com>
  10. # Date: 1997 - 2007
  11. # This file is part of the GNUstep Makefile Package.
  12. #
  13. # This library is free software; you can redistribute it and/or
  14. # modify it under the terms of the GNU General Public License
  15. # as published by the Free Software Foundation; either version 3
  16. # of the License, or (at your option) any later version.
  17. # You should have received a copy of the GNU General Public
  18. # License along with this library; see the file COPYING.
  19. # If not, write to the Free Software Foundation,
  20. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  21.  
  22. # 'opentool' is obsolete.  You can invoke your tools directly, just
  23. # put them in your PATH :-)
  24.  
  25. # Try to execute the GNUstep tool passed as argument. The tool is
  26. # searched through the GNUstep directories if a complete or relative path name
  27. # is not specified. The arguments passed after the tool name are passed
  28. # unmodified to the tool.
  29.  
  30. if [ -z "$1" ]; then
  31.   echo usage: `basename "$0"` [--library-combo=...] tool [arguments...]
  32.   echo `basename "$0"` --help for help
  33.   exit 1
  34. fi
  35.  
  36. # Try to determine GNUSTEP_MAKEFILES to source GNUstep.sh
  37. if [ -z "$GNUSTEP_CONFIG_FILE" ]; then
  38.   GNUSTEP_CONFIG_FILE=/etc/GNUstep/GNUstep.conf
  39. fi
  40.  
  41. if [ -z "$GNUSTEP_USER_CONFIG_FILE" ]; then
  42.   GNUSTEP_USER_CONFIG_FILE=.GNUstep.conf
  43. fi
  44.  
  45. if [ -f "$GNUSTEP_CONFIG_FILE" ]; then
  46.   . "$GNUSTEP_CONFIG_FILE"
  47. fi
  48.  
  49. GNUSTEP_HOME=~
  50.  
  51. if [ -n "$GNUSTEP_USER_CONFIG_FILE" ]; then
  52.   case "$GNUSTEP_USER_CONFIG_FILE" in 
  53.     /*) # An absolute path
  54.         if [ -f "$GNUSTEP_USER_CONFIG_FILE" ]; then
  55.           . "$GNUSTEP_USER_CONFIG_FILE"
  56.         fi;;
  57.      *) # Something else
  58.         if [ -f "$GNUSTEP_HOME/$GNUSTEP_USER_CONFIG_FILE" ]; then
  59.           . "$GNUSTEP_HOME/$GNUSTEP_USER_CONFIG_FILE"
  60.         fi;;
  61.   esac
  62. fi
  63.  
  64. if [ -z "$GNUSTEP_MAKEFILES" ]; then
  65.   GNUSTEP_MAKEFILES=/usr/share/GNUstep/Makefiles
  66. fi
  67. # OK, we now have GNUSTEP_MAKEFILES, source GNUstep.sh.
  68.  
  69. # Also, we'd like to get the GNUSTEP_*_TOOLS directories so we can
  70. # search them, so tell GNUstep.sh to export all variabes.
  71. GNUSTEP_SH_EXPORT_ALL_VARIABLES=yes
  72. . $GNUSTEP_MAKEFILES/GNUstep.sh
  73. unset GNUSTEP_SH_EXPORT_ALL_VARIABLES
  74.  
  75.  
  76. if [ -z "$EXEEXT" ]; then
  77.   EXEEXT=
  78. fi
  79.  
  80. # traps the parameters
  81. while true
  82. do 
  83.   case "$1" in
  84.     --library-combo=*)
  85.         tmp_makefiles="$GNUSTEP_MAKEFILES"
  86.         . "$tmp_makefiles/GNUstep-reset.sh"
  87.         LIBRARY_COMBO=`echo "$1" | sed 's/--library-combo=//'`
  88.         . "$tmp_makefiles/GNUstep.sh"
  89.         echo "Switched to library combo $LIBRARY_COMBO"
  90.         shift
  91.         ;;
  92.     --help)
  93.       echo usage: `basename "$0"` [--library-combo=...] tool [arguments...]
  94.       echo
  95.       echo tool is the complete or relative name of the tool executable
  96.       echo without any extension, like defaults
  97.       echo
  98.       echo [arguments...] are the arguments to the tool.
  99.       exit 0
  100.       ;;
  101.     *)
  102.       break;;
  103.   esac
  104. done
  105.  
  106. tool="$1";
  107. shift;
  108.  
  109. if [ -n "$EXEEXT" ]; then
  110.   tool="$tool$EXEEXT"
  111. fi
  112.  
  113. case "$tool" in
  114.   /*)    # An absolute path.
  115.       full_toolname="$tool";;
  116.   */*)    # A relative path
  117.     tool_dir=`dirname "$tool"`; 
  118.     tool_dir=`(cd "$tool_dir"; pwd)`; 
  119.     tool_name=`basename "$tool"`;
  120.     full_toolname="${tool_dir}/${tool_name}";;
  121.   *)    # A path that should be searched into GNUstep tool paths
  122.  
  123.         # Search for a local tool
  124.  
  125.         # We used to scan all ./*/$(GNUSTEP_HOST_LDIR)/ directories,
  126.         # but this facility was removed (GNUSTEP_HOST_LDIR is no
  127.         # longer even defined in this file), now we perform a much
  128.         # simpler search.
  129.  
  130.         # The really important one is looking into ./obj, anyway here
  131.         # is the order in which we search local directories - 
  132.         # First, we search in ./
  133.         # Second, we search in ./obj
  134.         # Third, we search in ./Tools/
  135.         # Fourth, we search in ./Tools/obj
  136.         for dir in . obj Tools Tools/obj; do
  137.           # echo "$dir/$tool";
  138.           if [ -x "$dir/$tool" ]; then
  139.             full_toolname="$dir/$tool"
  140.             # echo "Found: $dir/$tool";
  141.             break;
  142.           fi
  143.         done
  144.  
  145.     if [ -z "$full_toolname" ]; then 
  146.           
  147.           # Local tool not found - Search for an installed one
  148.           # we search in the order in:
  149.           # GNUSTEP_USER_TOOLS
  150.           # GNUSTEP_LOCAL_TOOLS
  151.           # GNUSTEP_NETWORK_TOOLS
  152.           # GNUSTEP_SYSTEM_TOOLS
  153.       #
  154.       # We look in the GNUSTEP_HOST_CPU/GNUSTEP_HOST_OS/LIBRARY_COMBO
  155.       # subdirectory first, then the GNUSTEP_HOST_CPU/GNUSTEP_HOST_OS
  156.       # subdirectory, then the top-level directory.
  157.       # (For flattened systems we skip the first two options.
  158.       #
  159.           # TODO: Also search Admin Tools directories if appropriate
  160.       for dir in "$GNUSTEP_USER_TOOLS" "$GNUSTEP_LOCAL_TOOLS" "$GNUSTEP_NETWORK_TOOLS" "$GNUSTEP_SYSTEM_TOOLS" ; do
  161.         if [ "$GNUSTEP_IS_FLATTENED" = "no" ]; then
  162.           tmpgnudir="$dir/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS"
  163.           tmplibdir="$dir/$GNUSTEP_HOST_CPU/$GNUSTEP_HOST_OS/$LIBRARY_COMBO"
  164.           # echo "$tmplibdir/$tool";
  165.           if [ -x "$tmplibdir/$tool" ]; then
  166.         # echo "Found: $tmplibdir/$tool";
  167.         full_toolname="$tmplibdir/$tool"
  168.         break;
  169.           fi
  170.           if [ -x "$tmpgnudir/$tool" ]; then
  171.         # echo "Found: $tmpgnudir/$tool";
  172.         full_toolname="$tmpgnudir/$tool"
  173.         break;
  174.           fi
  175.         fi
  176.         # echo "$dir/$tool";
  177.         if [ -x "$dir/$tool" ]; then
  178.           # echo "Found: $dir/$tool";
  179.           full_toolname="$dir/$tool"
  180.           break;
  181.         fi
  182.         done
  183.         unset tmpgnudir
  184.         unset tmplibdir
  185.       fi
  186.         ;;
  187. esac
  188.  
  189. if [ -z "$full_toolname" ]; then
  190.   echo "Can't find the required tool: $tool!"
  191.   exit 1
  192. fi
  193.  
  194. "$full_toolname" "$@"
  195.  
  196.